//
//  DatalLoadFaildView.swift
//  ezyform
//
//  Created by MoennigQ on 20/11/20.
//  Copyright © 2020 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit

class DatalLoadFaildView: View {
    let retryBtn = OperationButton(R.string.localizable.retrY())
    
    override func setUpView() {
        self.backgroundColor = .white
        //
        let backView = UIView()
        backView.backgroundColor = .white
        self.addSubview(backView)
        backView.snp.makeConstraints { make in
            make.height.greaterThanOrEqualTo(0)
            make.left.equalTo(30)
            make.right.equalTo(-30)
            make.centerY.equalToSuperview()
        }
        //faild imageview
        let faildImageView = UIImageView(image: R.image.installation_detail_load_faild_icon())
        faildImageView.contentMode = .scaleAspectFit
        backView.addSubview(faildImageView)
        faildImageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.height.lessThanOrEqualTo(150)
            make.width.greaterThanOrEqualTo(0)
            make.centerX.equalToSuperview()
        }
        //networkAccessFailure
        let tipOneLabel = ContentLabel(R.font.interBold(size: 18))
        tipOneLabel.numberOfLines = 0
        tipOneLabel.textAlignment = .center
        tipOneLabel.text = R.string.localizable.networkAccessFailure()
        backView.addSubview(tipOneLabel)
        tipOneLabel.snp.makeConstraints { make in
            make.top.equalTo(faildImageView.snp.bottom).offset(20)
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
        }
        //networkAccessFailure
        let tipTwoLabel = ContentLabel(R.font.interMedium(size: 13))
        tipTwoLabel.numberOfLines = 0
        tipTwoLabel.textAlignment = .center
        tipTwoLabel.text = R.string.localizable.pleaseCheckYourNetworkConnectionAndTryAgain()
        backView.addSubview(tipTwoLabel)
        tipTwoLabel.snp.makeConstraints { make in
            make.top.equalTo(tipOneLabel.snp.bottom).offset(12)
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
        }
        //retry btn
        backView.addSubview(retryBtn)
        retryBtn.snp.makeConstraints { (make) in
            make.top.equalTo(tipTwoLabel.snp.bottom).offset(40)
            make.height.equalTo(OperationButton.height)
            make.width.equalTo(200)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }
}
